﻿using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

public class GPUTerrainPass : ScriptableRenderPass
{
    public static Action<ScriptableRenderContext, Camera> ExecuteAction;

    private RenderTargetIdentifier colorRTIdentifier;
    private RenderTargetIdentifier depthRTIdentifier;

    public GPUTerrainPass(RenderPassEvent evt)
    {
        this.renderPassEvent = evt;
    }

    public bool Setup(RenderTargetIdentifier colorRTIdentifier, RenderTargetIdentifier depthRTIdentifier)
    {
        this.colorRTIdentifier = colorRTIdentifier;
        this.depthRTIdentifier = depthRTIdentifier;

        return true;
    }

    public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
    {
        ConfigureTarget(colorRTIdentifier, depthRTIdentifier);
    }

    public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    {
        ExecuteAction?.Invoke(context, renderingData.cameraData.camera);
    }

}
